package com.zenithmind.news.config;

/**
 * 新闻服务端点配置 - 遵循单一职责原则
 * 专门负责定义各种端点路径，与安全配置分离
 * 
 * @author ZenithMind Team
 * @since 2025-01-09
 */
public final class NewsEndpointConfig {

    private NewsEndpointConfig() {
        // 工具类，禁止实例化
    }

    /**
     * API文档相关端点
     */
    public static final String[] API_DOC_ENDPOINTS = {
        "/v3/api-docs/**",
        "/swagger-ui/**",
        "/swagger-ui.html",
        "/doc.html",
        "/webjars/**",
        "/favicon.ico",
        "/knife4j/**",
        "/knife4j-ui/**",
        "/knife4j.html"
    };

    /**
     * 公开访问端点 - 不需要认证
     */
    public static final String[] PUBLIC_ENDPOINTS = {
        // 新闻公开查询端点
        "/api/zenithMind/v1/news/query/**",
        "/api/zenithMind/v1/news/*/detail",
        "/api/zenithMind/v1/news/page",
        // 健康检查端点
        "/actuator/**",
        "/health",
        "/info"
    };

    /**
     * 用户级别端点 - 需要用户认证
     */
    public static final String[] USER_ENDPOINTS = {
        "/api/zenithMind/v1/news/interaction/**",
        "/api/zenithMind/v1/news/*/like",
        "/api/zenithMind/v1/news/*/favorite",
        "/api/zenithMind/v1/news/*/share"
    };

    /**
     * 编辑级别端点 - 需要编辑权限
     */
    public static final String[] EDITOR_ENDPOINTS = {
        "/api/zenithMind/v1/news",
        "/api/zenithMind/v1/news/*",
        "/api/zenithMind/v1/news/*/publish",
        "/api/zenithMind/v1/news/*/unpublish",
        "/api/zenithMind/v1/news/*/review"
    };

    /**
     * 管理员级别端点 - 需要管理员权限
     */
    public static final String[] ADMIN_ENDPOINTS = {
        "/api/zenithMind/v1/news/statistics/**",
        "/api/zenithMind/v1/news/admin/**"
    };

    /**
     * WebSocket端点
     */
    public static final String[] WEBSOCKET_ENDPOINTS = {
        "/ws/news"
    };

    /**
     * 获取所有需要跳过认证的端点
     */
    public static String[] getAllPublicEndpoints() {
        String[] combined = new String[API_DOC_ENDPOINTS.length + PUBLIC_ENDPOINTS.length];
        System.arraycopy(API_DOC_ENDPOINTS, 0, combined, 0, API_DOC_ENDPOINTS.length);
        System.arraycopy(PUBLIC_ENDPOINTS, 0, combined, API_DOC_ENDPOINTS.length, PUBLIC_ENDPOINTS.length);
        return combined;
    }
}
